Python NumPy hsplit Function

34

# welcome to softhunt.net
# Horizontal array splitting using np.hsplit()
import numpy as np


# Making of a 3x3 array
a = np.arange(9).reshape(3, 3)

# Horizontal splitting of array
# 'a' using np.hsplit().
print("The array: \n {} \n\n gets splitted horizontally to form: \n {} ".format(a, np.hsplit(a, 3)))

# Horizontal splitting of array 'a'
# using 'split' with axis parameter = 1.
print("\n The array: \n {} \n\n gets splitted horizontally to form: \n {} ".format(a, np.split(a, 3, 1)))

Comments

Submit
0 Comments